//
//  WithDrawListCell.m
//  rdxny
//
//  Created by nsm on 2018/5/5.
//  Copyright © 2018年 rdxny. All rights reserved.
//

#import "WithDrawListCell.h"

@implementation WithDrawListCell {
    UILabel *_timeLabel;
    UILabel *_typeLabel;
    UILabel *_contentLabel;
    UILabel *_rightLabel;
    UILabel *_statusLabel;
}

- (void)setObject:(id)obj {
    _timeLabel.text = obj[@"createtime"];
    // _typeLabel.text = obj[@"type_name"];
    _rightLabel.attributedText = AttributedString(obj[@"money"],
                                                  CustomFont(18),
                                                  THEME_COLOR,
                                                  @"\n提现金额",
                                                  CustomFont(14),
                                                  COLOR_1,
                                                  NSTextAlignmentRight,
                                                  0);
    _statusLabel.text = obj[@"status_name"];
    _statusLabel.backgroundColor = HexColor(obj[@"status_color"]);
    
    NSString *content = SafeString(obj[@"content"]);
    if (content.length) {
        _contentLabel.myVisibility = MyVisibility_Visible;
        _contentLabel.text = FormatString(@"原因: %@", content);
    } else
        _contentLabel.myVisibility = MyVisibility_Gone;
}

- (void)setupSubviews {
    MyLinearLayout *rootLayout = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    rootLayout.backgroundColor = GROUP_TABLECOLOR;
    rootLayout.cacheEstimatedRect = YES;
    rootLayout.myHorzMargin = 0;
    rootLayout.padding = UIEdgeInsetsMake(12, 12, 0, 12);
    rootLayout.gravity = MyGravity_Horz_Fill;
    [self.contentView addSubview:rootLayout];
    self.rootLayout = rootLayout;
    
    MyLinearLayout *layout = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
    layout.padding = UIEdgeInsetsMake(12, 12, 12, 20);
    layout.backgroundColor = COLOR_4;
    layout.wrapContentHeight = YES;
    layout.subviewHSpace = 4;
    layout.gravity = MyGravity_Vert_Center;
    [rootLayout addSubview:layout];
    ViewCorner(layout, 6);
    
    MyFlowLayout *flow = [MyFlowLayout flowLayoutWithOrientation:MyOrientation_Vert arrangedCount:2];
    flow.weight = 1;
    flow.wrapContentHeight = YES;
    flow.subviewHSpace = 6;
    flow.subviewVSpace = 2;
    flow.arrangedGravity = MyGravity_Vert_Center;
    [layout addSubview:flow];
    
    UIImageView *icon = [UIImageView new];
    icon.mySize = CGSizeMake(21, 21);
    icon.tintColor = COLOR_1;
    icon.image = TemplateImage(@"icon_withdraw_time");
    [flow addSubview:icon];
    
    NSArray *items = @[@"站点地址" , @"", @"", @""];
    for (int i=0; i<items.count; i++) {
        UILabel *label = [UILabel new];
        if (i!=2) label.weight = 1;
        label.wrapContentHeight = YES;
        label.textColor = COLOR_1;
        label.font = CustomFont(15);
        label.text = items[i];
        [flow addSubview:label];
        
        if (i==0)
            _timeLabel = label;
        else if (i==1)
            _typeLabel = label;
        else if (i==3) {
            label.textColor = [UIColor redColor];
            _contentLabel = label;
        }
    }
    
    UILabel *label = [UILabel new];
    label.wrapContentSize = YES;
    [layout addSubview:label];
    _rightLabel = label;
    
    UILabel *statusLabel = [UILabel new];
    statusLabel.size = CGSizeMake(100, 15);
    statusLabel.textColor = COLOR_4;
    statusLabel.font = CustomFont(8);
    statusLabel.useFrame = YES;
    statusLabel.textAlignment = NSTextAlignmentCenter;
    statusLabel.center = CGPointMake(kScreenWidth-12*3-4, 15);
    [layout addSubview:statusLabel];
    statusLabel.transform = CGAffineTransformMakeRotation(M_PI_4);
    _statusLabel = statusLabel;
}

@end
